!********************
MODULE metric
!********************
USE ElliDef
IMPLICIT NONE
SAVE
PRIVATE

PUBLIC g,g_mask



CONTAINS

ELEMENTAL REAL (KIND=Precision) FUNCTION g(i,j,k,l,p)
! returns \sqrt(g)glp at location i,j,k
! NOTE THAT WHEN l==p IT IS RETURNED AT THE CORRESPONDING
! CELL EDGE
INTEGER, INTENT (IN) :: i,j,k,l,p

REAL (KIND=Precision) :: xi,eta,zeta




SELECT CASE( (l-1)*3+p)
CASE (-3) !\sqrt(g)
g=one

CASE (1) !g11

g=one
CASE (5) !g22

g=one
CASE (9) ! g33

g=one



CASE (2,4) ! g12

g=one


CASE (3,7) ! g13

g=one

CASE (6,8) ! g 23


g=one

END SELECT
END FUNCTION g


LOGICAL FUNCTION g_mask(i,j)

INTEGER, INTENT (IN) :: i,j
SELECT CASE ((i-1)*3+j)
CASE(1) ! 11
g_mask=.true.   
CASE(5) ! 22
g_mask=.true.   
CASE(9) ! 33
g_mask=.true.   
CASE(2,4) ! 12 or 21
g_mask=.true.   
CASE(3,7) ! 13 or 31
g_mask=.true.   
CASE(6,8)  ! 23 or 32
g_mask=.true.   

END SELECT
END FUNCTION g_mask
END MODULE metric
